#!/bin/bash

set -ue

export DEBUG=1
export CPATH=`pwd`
export TOOLS="$CPATH/tools"
export HOME="/root"

#load the configure
. config.sh || exit 1
if echo "$CI_PROJECT" | grep '_gcov'; then
     modify_for_gcov $CPATH
     . config.sh || exit 1
fi

export ERROR_LOG="$CPATH/error_log"
export version=
export EULEROS_CHROOT_PATH=/usr1/euleros

export MOUNTDIR_MASTER="//$ICP_CI_IP/mount_for_linux"
export MOUNTDIR_AGENT="/home/mount_for_linux"
export MASTER_USER="Administrator"
export MASTER_PASSWD="EulerOS_123"


HTTP_DIR="/srv/www/htdocs"
PRE_VERSION='internal_use_only/EulerOS/EulerOS_V200R008C00'
set +u
if [ "x${team_from_jenkins}" != "x" ]; then
    PRE_VERSION="internal_use_only/EulerOS_${team_from_jenkins}/EulerOS_V200R008C00"
fi
set -u
VERSION="$CI_PROJECT"
TYPE="Release"
if [ "$ISCI" -eq 0 ]; then
    export version="$MYVERSION"
fi
export PRODUCTS="CE Logic_Part MSP PANGEA N9000 EVR SVP EULEROS_BASIC UNIFIEDSTORAGE CSP ATLAS RED DORADO DORADO_DEBUG MBSC cgp_mem cgp_disk VNE"
export SCRIPT=""
export exclude_register_script=('set_release_dir')

. common_function.sh || exit 1


function usage()
{
    echo "`basename $0` [script_name|all]"
}

export all_scripts=('set_release_dir' 'build_and_wait' 'make_tar' 'make_tar_pangea' 'make_iso' 'make_compile_env' 'make_compile_env_storage' 'make_compile_env_dorado')
[[ $DEBUG -eq 1 ]] && set -x

check_env

arg1=$1
shift
arg2=$@
if [ $arg1 == 'all' -o -z $arg1 ]; then
    run_srcipt_all
else
    run_srcipt $arg1 $arg2
fi
